<?php

namespace App\Http\Controllers;

use App\Library\Service\DouyinService;
use App\Library\YsdLib;
use Illuminate\Http\JsonResponse;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Pay\Pay;

class DouyinController extends BaseController
{
    /**
     * @param DouyinService $service
     * @throws ContainerException
     */
    public function __construct(DouyinService $service)
    {
        $this->service = $service;
        Pay::config(YsdLib::config('douyin'));
    }

    /**
     * notify
     * @return JsonResponse
     */
    public function notify(): JsonResponse
    {
        payLog(request()->all());
        return success();
    }

    /**
     * create
     * @return JsonResponse
     */
    public function create(): JsonResponse
    {
        return $this->service->mini(serialNumber(), 1);
    }
}
